<?php

/*
	This file is part of Mandragon.

    Mandragon is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Mandragon is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Mandragon.  If not, see <http://www.gnu.org/licenses/>.
*/

require_once 'PHPUnit/Framework.php';
require_once 'autoload.php';

class TestDateFormatter extends PHPUnit_Framework_TestCase {

	function test_format_decades_ago() {
		
		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('-30 year'));
		$this->assertEquals("3 decennia geleden", $formatter->format($testdate)); //TODO: adapt test: return text should read "1 decennium geleden" for singular.
	}

	function test_format_decades_in_the_future() {
		
		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('+20 year'));
		$this->assertEquals("over 2 decennia", $formatter->format($testdate)); //TODO: adapt test: return text should read "over 1 decennium" for singular.
	}

	function test_format_years_ago() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('-2 year'));
		$this->assertEquals("2 jaar geleden", $formatter->format($testdate));
	}

	function test_format_years_in_the_future() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('+2 year'));
		$this->assertEquals("over 2 jaar", $formatter->format($testdate));
	}

	function test_format_months_ago() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('-2 month'));
		$this->assertEquals("2 maand geleden", $formatter->format($testdate));
	}

	function test_format_months_in_the_future() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('+2 month'));
		$this->assertEquals("over 2 maand", $formatter->format($testdate));
	}

	function test_format_weeks_ago() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('-2 week'));
		$this->assertEquals("2 weken geleden", $formatter->format($testdate));
	}

	function test_format_weeks_in_the_future() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('+2 week'));
		$this->assertEquals("over 2 weken", $formatter->format($testdate));
	}

	function test_format_days_ago() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('-2 day'));
		$this->assertEquals("2 dagen geleden", $formatter->format($testdate));
	}

	function test_format_days_in_the_future() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d', strtotime('+2 day'));
		$this->assertEquals("over 2 dagen", $formatter->format($testdate));
	}

	function test_format_hours_ago() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d H:i:s', strtotime('-2 hour'));
		$this->assertEquals("2 uur geleden", $formatter->format($testdate));
	}

	function test_format_hours_in_the_future() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d H:i:s', strtotime('+2 hour'));
		$this->assertEquals("over 2 uur", $formatter->format($testdate));
	}

	function test_format_minutes_ago() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d H:i:s', strtotime('-2 minute'));
		$this->assertEquals("2 minuten geleden", $formatter->format($testdate));
	}

	function test_format_minutes_in_the_future() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d H:i:s', strtotime('+2 minute'));
		$this->assertEquals("over 2 minuten", $formatter->format($testdate));
	}

	function test_format_seconds_ago() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d H:i:s', strtotime('-2 second'));
		$this->assertEquals("2 seconden geleden", $formatter->format($testdate));
	}

	function test_format_seconds_in_the_future() {

		$formatter = new DateFormatter();

		$testdate = date('Y-m-d H:i:s', strtotime('+2 second'));
		$this->assertEquals("over 2 seconden", $formatter->format($testdate));
	}
}

?>
